-
Notifications
You must be signed in to change notification settings - Fork 41
feat(trainer): Add environment variables argument to CustomTrainer #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pull Request Test Coverage Report for Build 16677180921Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
@eoinfennessy: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @astefanutti!
I have general question, when do you think we should recommend users to use env or func_args ?
I can imagine that system env should be configured by Platform Admins.
| pip_index_url (`Optional[str]`): The PyPI URL from which to install Python packages. | ||
| num_nodes (`Optional[int]`): The number of nodes to use for training. | ||
| resources_per_node (`Optional[Dict]`): The computing resources to allocate per node. | ||
| env (`Optional[Dict[str, str]]`): Environment variables to set in the training containers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be more explicit, since SDK users should not be aware of containers ?
| env (`Optional[Dict[str, str]]`): Environment variables to set in the training containers. | |
| env (`Optional[Dict[str, str]]`): The environment variables to set in the training nodes. |
| if trainer.env: | ||
| env_vars = [] | ||
| for key, value in trainer.env.items(): | ||
| env_vars.append( | ||
| models.IoK8sApiCoreV1EnvVar( | ||
| name=key, | ||
| value=value | ||
| ) | ||
| ) | ||
| trainer_crd.env = env_vars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this:
| if trainer.env: | |
| env_vars = [] | |
| for key, value in trainer.env.items(): | |
| env_vars.append( | |
| models.IoK8sApiCoreV1EnvVar( | |
| name=key, | |
| value=value | |
| ) | |
| ) | |
| trainer_crd.env = env_vars | |
| if trainer.env: | |
| trainer_crd.env = [ | |
| models.IoK8sApiCoreV1EnvVar(name=key, value=value) | |
| for key, value in trainer.env.items() | |
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you @astefanutti!
| if add_built_in_trainer: | ||
| train_job = add_built_in_trainer_to_job(train_job) | ||
| if add_custom_trainer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if add_built_in_trainer: | |
| train_job = add_built_in_trainer_to_job(train_job) | |
| if add_custom_trainer: | |
| if add_built_in_trainer: | |
| train_job = add_built_in_trainer_to_job(train_job) | |
| elif add_custom_trainer: |
| if trainer.env: | ||
| env_vars = [] | ||
| for key, value in trainer.env.items(): | ||
| env_vars.append( | ||
| models.IoK8sApiCoreV1EnvVar( | ||
| name=key, | ||
| value=value | ||
| ) | ||
| ) | ||
| trainer_crd.env = env_vars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Signed-off-by: Antonin Stefanutti <antonin@stefanutti.fr>
Signed-off-by: Antonin Stefanutti <antonin@stefanutti.fr>
|
@andreyvelich @kramaranya thanks a lot for the review. I should have addressed all your comments. |
|
Thank you for this, @astefanutti! |
I would say this is convenient and useful for AI practitioners to be able to pass environment variables like On the other hand At least for custom trainers, I would be inclined to think users would prefer being able to pass these variables directly than asking platform admins to configure them each time on training runtimes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@astefanutti Thanks for creating this! Overall LGTM!
/lgtm
Signed-off-by: Antonin Stefanutti <antonin@stefanutti.fr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @astefanutti!
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andreyvelich The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
This enables users to pass environment variables to the custom trainer.
/assign @kubeflow/kubeflow-trainer-team @szaher @kramaranya @eoinfennessy @briangallagher
Checklist: